package codetop.microsoft.T198;

/**
 * @Author: 18362
 * @Create: 2022-08-15 10:45:49 星期一
 */
class Solution {
    public int rob(int[] nums) {
        int dp1 = nums[0], dp2 = 0;
        for (int i=1; i<nums.length; ++i) {
            int t = Math.max(dp1, dp2 + nums[i]);
            dp2 = dp1;
            dp1 = t;
        }
        return Math.max(dp1, dp2);
    }
}